package com.chixing.day03_oop;

public class ProductTest {
    public static void main(String[] args) {
        Product[] product = new Product[10];
        product[0] = new Product(1,"手机",2999,"北京");
        product[1] = new Product(2,"电脑",5999,"天津");
        product[2] = new Product(3,"电视",3000,"上海");
        product[3] = new Product(4,"相机",1000,"广州");
        product[4] = new Product(5,"冰箱",2500,"江苏");
        product[5] = new Product(6,"空调",3000,"浙江");
        product[6] = new Product(7,"外套",200,"湖北");
        product[7] = new Product(8,"裤子",100,"海南");
        product[8] = new Product(9,"鞋子",500,"江西");
        product[9] = new Product(10,"帽子",50,"广西");

        for (int i=0;i<product.length;i++){
            System.out.println("商品ID:"+product[i].getProductId()+" 商品名称:"+product[i].getProductName());
        }
        for (int i=0;i<product.length;i++){
            if (product[i].getProductPrice()>300)
                System.out.println(product[i].getProductName());
        }
        for (int i=0;i<product.length-1;i++){
            for (int j=i+1;j<product.length;j++){
                if (product[i].getProductPrice()>product[j].getProductPrice()){
                    Product[] temp = new Product[1];
                    temp[0] = product[i];
                    product[i] = product[j];
                    product[j] = temp[0];
                }
            }
        }
        for (int i=0;i<product.length;i++){
            System.out.println("商品ID:"+product[i].getProductId()+" 商品名称:"+product[i].getProductName()
                            +" 商品名称:"+product[i].getProductPrice());
        }




    }
}
